#!/bin/bash
echo "开始迁移 !"

sourcefile="file://mysql"
# database="mysql://root:123456@tcp(127.0.0.1:3306)/sunny?multiStatements=true"
database="mysql://root:Tm4FN5pg99b0BlAUs@tcp(20.198.170.39:3306)/sunny?charset=utf8&parseTime=true"
path="/Users/villian/app/sunny/api/tools/migrations/"
dirpath="mysql"

case $1 in
up)
    migrate -verbose -source $sourcefile  -path $path -database $database up $2
    ;;
down)
    migrate -verbose -source $sourcefile  -path $path -database $database down $2
    ;;
force)
     migrate -verbose -source $sourcefile  -path $path -database $database force $2
    ;;
create)
     migrate create -ext sql -dir $dirpath $2
    ;;
*)  echo '请输入参数 up down 或者'
    ;;
esac

# migrate -verbose -source file://mysql -path /Users/villian/app/wallet/server/tools/migrations/ -database mysql://root:123456@tcp(127.0.0.1:3306)/wallet?multiStatements=true up                 
